//
//  NicknameController.m
//  JZRJAPP
//
//  Created by mac on 16/6/1.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "NicknameController.h"
#import "SettingViewController.h"
@interface NicknameController ()
@property (nonatomic,strong) UIView *topView;
@property (nonatomic,strong)UILabel *titleLabel;
@property (nonatomic,strong)UITextField *nameText;

@end

@implementation NicknameController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor =[UIColor whiteColor];
    self.topView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 64)];
    _topView.backgroundColor =[UIColor redColor];
    
    UIButton *leftBtn =[UIButton buttonWithType:UIButtonTypeCustom];
    
    leftBtn.frame =CGRectMake(5, 15, 50, 50);
    [leftBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    
    //[leftBtn setTitle:@"返回" forState:UIControlStateNormal];
    [leftBtn addTarget:self action:@selector(backClick:) forControlEvents:UIControlEventTouchUpInside];
    
    self.titleLabel =[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH / 2 -50, 20, 100, 40)];
    self.titleLabel.text = @"昵称";
    self.titleLabel.font = [UIFont systemFontOfSize:20];
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    self.titleLabel.textColor = [UIColor whiteColor];
    
    
    UIButton *rightBtn =[UIButton buttonWithType:UIButtonTypeCustom];
    rightBtn.frame =CGRectMake(SCREEN_WIDTH - 65, 15, 50, 50);
    
    [rightBtn setTitle: @"保存" forState:UIControlStateNormal];
    
    [rightBtn addTarget:self action:@selector(baocun:) forControlEvents:UIControlEventTouchUpInside];
    
    [self.topView addSubview:rightBtn];

    [self.topView addSubview:leftBtn];
    [self.topView addSubview:self.titleLabel];
    
    
    self.nameText = [[UITextField alloc]initWithFrame:CGRectMake(30, 80, SCREEN_WIDTH/ 5 * 4, 40)];
    self.nameText.backgroundColor = [UIColor greenColor];
    self.nameText.layer.cornerRadius = 5;
    self.nameText.text = self.name;
    self.nameText.clearButtonMode = UITextFieldViewModeAlways;
    self.nameText.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    
    [self.view addSubview:self.nameText];
    [self.view addSubview:self.topView];
     

    // Do any additional setup after loading the view.
}

-(void)backClick:(UIButton *)sender{
    
    [self dismissViewControllerAnimated:YES completion:nil];
    
    
}

-(void)baocun:(UIButton *)sender{
    
 
    
    [self.delegate inputString:self.nameText.text];
     
    [self dismissViewControllerAnimated:YES completion:nil];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
